/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-30 12:44:21
 * @LastEditTime: 2021-08-30 16:22:25
 * @LastEditors: changqing
 * @Usage: 
 */

// 会持续触发来源Observable的事件什，直到untile指定的别个一个Observalbe发生新事件时，才会结束。


var { timer, interval,range } = require('rxjs'); 
var {takeUntil,map} = require('rxjs/operators');

const click = fromEvent(document.querySelector('#btnStop'), 'click'); 
const source = interval(1000).pipe(map(data => data + 1))

source.pipe(
  takeUntil(click)
).subscribe({
  next: data => console.log(` ${data}`),
  complete: () => console.log('takeUntil complete')
});


// setTimeout(()=>{
//   rangeSource.subscribe(
//     data => console.log(`range 示範: ${data}`)
//   );
// },5000);

// 1 2 3 4 5
// takeUntil complete